﻿using Castle.MicroKernel.Registration;
using Icms.Core.Model;
using Icms.Core.Repository;
using Icms.Core.Security;
using Icms.Core.Service;
using Icms.Data;
using Icms.Infra;
using Icms.WebUI.Builder;
using Icms.Service;
using Icms.WebUI.Controllers;
using Icms.WebUI.Dto;

namespace Icms.WebUI
{
    public class WindsorConfigurator
    {
        public static void Configure()
        {
            //IoC.Container.Register(
            //    Component.For<IDbContextFactory>().ImplementedBy<DbContextFactory>().Named("dbcontext"));

            //WindsorRegistrar.RegisterTransient(typeof(IConnectionFactory), typeof(ConnectionFactory));
            //WindsorRegistrar.RegisterTransient(typeof(IReportRepo), typeof(ReportRepo));

            WindsorRegistrar.Register(typeof(IFormsAuthentication), typeof(FormAuthService));
            WindsorRegistrar.Register(typeof(IPdf), typeof(Pdf));
            WindsorRegistrar.Register(typeof(IMapper<Hearing,HearingInput>), typeof(HearingMapper));

            WindsorRegistrar.Register(typeof(IParticipantMapper<Participant,ParticipantCreateInput>), typeof(ParticipantMapper<ParticipantCreateInput>));
            WindsorRegistrar.Register(typeof(IParticipantMapper<Participant,ParticipantEditInput>), typeof(ParticipantMapper<ParticipantEditInput>));

            WindsorRegistrar.Register(typeof(ICrudService<Participant>), typeof(ParticipantService));

            WindsorRegistrar.RegisterAllFromAssemblies("Icms.Data");
            WindsorRegistrar.RegisterAllFromAssemblies("Icms.Service");
            WindsorRegistrar.RegisterAllFromAssemblies("Icms.WebUI");
            
            
            //IoC.Container.Register(
            //    Component.For<IDbContextFactory>().ImplementedBy<DbContextFactory>()
            //    .LifeStyle.Transient.Named("transientDbContext"));

            //IoC.Container.Register(
            //    Component.For(typeof (IRepo<>)).ImplementedBy(typeof (Repo<>)).LifeStyle.Transient
            //    .Named("transientRepo").DependsOn(ServiceOverride.ForKey("dbcontext").Eq("transientDbContext")));
        }
    }
}